package com.wuseguang.springcloud.dao.repository;

import com.wuseguang.springcloud.entity.GroupStudent;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;

public interface GroupStudentRepository  extends JpaRepository<GroupStudent,Integer> {

    //删除需要加 @Modifying @Transactional
    @Transactional
    @Modifying
    @Query(value = "DELETE FROM group_student WHERE group_id =?1",nativeQuery=true)
    Integer deleteByGroupId(Integer id);

    //删除需要加 @Modifying @Transactional
    @Transactional
    @Modifying
    @Query(value = "DELETE FROM group_student WHERE student_id =?1",nativeQuery=true)
    Integer deleteByStudentId(Integer sutdentId);
}
